/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Jirka
 */
@Entity
@Table(name = "suspension")
@NamedQueries({@NamedQuery(name = "Suspension.findAll", query = "SELECT s FROM Suspension s"), @NamedQuery(name = "Suspension.findByReason", query = "SELECT s FROM Suspension s WHERE s.reason = :reason"), @NamedQuery(name = "Suspension.findByPenalty", query = "SELECT s FROM Suspension s WHERE s.penalty = :penalty"), @NamedQuery(name = "Suspension.findByEventId", query = "SELECT s FROM Suspension s WHERE s.eventId = :eventId")})
public class Suspension implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "reason")
    private String reason;
    @Column(name = "penalty")
    private Integer penalty;
    @Id
    @Basic(optional = false)
    @Column(name = "event_id")
    private Integer eventId;
    @JoinColumn(name = "event_id", referencedColumnName = "event_id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Event event;

    public Suspension() {
    }

    public Suspension(Integer eventId) {
        this.eventId = eventId;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Integer getPenalty() {
        return penalty;
    }

    public void setPenalty(Integer penalty) {
        this.penalty = penalty;
    }

    public Integer getEventId() {
        return eventId;
    }

    public void setEventId(Integer eventId) {
        this.eventId = eventId;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (eventId != null ? eventId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Suspension)) {
            return false;
        }
        Suspension other = (Suspension) object;
        if ((this.eventId == null && other.eventId != null) || (this.eventId != null && !this.eventId.equals(other.eventId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Suspension[eventId=" + eventId + "]";
    }

}
